if SERVER then
	registerCommand("ragdoll", "Causes you to turn on/off ragdoll the player you specify", function(param)
		local ragOn = "caller ragdolled target"
		local ragOff = "caller unragdolled target"
		if param["settings"]["ragdoll_msg_on"] then
			ragOn = param["settings"]["ragdoll_msg_on"]
		end
		if param["settings"]["ragdoll_msg_off"] then
			ragOff = param["settings"]["ragdoll_msg_off"]
		end
		local ragTable = {}
		ragTable["caller"] = getCaller(param[1])
		local plys = string.Explode(" ", param[3])
		for i, targ in pairs(plys) do
			local plyTarg = getPlayerByName(targ)
			if plyTarg then
				ragTable["target"] = plyTarg:GetName()
				if (not plyTarg["moocow_rag"]) || plyTarg["moocow_rag"] == -1 then
					plyTarg["moocow_rag"] = 1
					local callerWeaps = {}
					for i, weap in pairs (plyTarg:GetWeapons()) do
						callerWeaps[i] = weap:GetClass()
					end
					plyTarg["moocow_ragweaps"] = callerWeaps
					plyTarg["moocow_ragactweap"] = plyTarg:GetActiveWeapon():GetClass()
					plyTarg:StripWeapons()
					plyTarg:DrawViewModel(false)
					plyTarg:DrawWorldModel(false)
					local prop = ents.Create("prop_ragdoll")
					prop:SetModel(plyTarg:GetModel())
					prop:SetPos(plyTarg:GetPos())
					prop:SetAngles(plyTarg:GetAngles())
					prop:Spawn()
					prop:Activate()
					plyTarg:SetParent(prop)
					local vel = plyTarg:GetVelocity()
					for x = 1, 14 do
						prop:GetPhysicsObjectNum(x):SetVelocity(vel)
					end
					//plyTarg:DisallowSpawning(true)
					plyTarg:Spectate(OBS_MODE_CHASE)
					plyTarg:SpectateEntity(prop)
					
					display(param[1], "ragdoll", { plyTarg } , parseDisplayMessage(ragOn, ragTable))
				else
					plyTarg["moocow_rag"] = -1
					//plyTarg:DisallowSpawning(false)
					plyTarg:UnSpectate()
					plyTarg:DrawViewModel(true)
					plyTarg:DrawWorldModel(true)
					local prop = plyTarg:GetParent()
					plyTarg:SetParent()
					prop:Remove()
					for i, weap in pairs(plyTarg["moocow_ragweaps"]) do
						plyTarg:Give(weap)
					end
					plyTarg:SelectWeapon(plyTarg["moocow_ragactweap"])
					plyTarg:Spawn()
					plyTarg:SetPos(prop:GetPos())
					plyTarg:SetVelocity(prop:GetVelocity())
					display(param[1], "ragdoll", { plyTarg } , parseDisplayMessage(ragOff, ragTable))
				end
			end
		end
	end)
end